<template>
  <div style="padding: 10px">
    <div class="narrow-container">
      <!-- 表单 -->
      <el-form ref="form" :model="formData" label-width="120px" style="margin-top: 20px;">
        <el-form-item label="用户名">
          <el-input v-model="formData.userName" style="width: 80%"/>
        </el-form-item>
        <el-form-item label="昵称">
          <el-input v-model="formData.nickName" style="width: 80%"/>
        </el-form-item>
        <el-form-item label="邮箱">
          <el-input v-model="formData.email" style="width: 80%"/>
        </el-form-item>
        <el-form-item label="电话">
          <el-input v-model="formData.phone"/>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm">提交</el-button>
        </el-form-item>
      </el-form>
    </div>

  </div>
</template>

<script>
import request from "@/utils/request";

export default {
  name: "PersonalCenter",
  components: {

  },
  data() {
    return {
      formData: {
        userName: '',
        nickName: '',
        email: '',
        phone: ''
      },
    };
  },
  methods: {
    submitForm() {
      const formDataToSend = this.formData;
      request.put("/user/updateUser", formDataToSend).then(res => {
        if (res.code === '0') {
          this.$message({
            type: "success",
            message: "更新成功"
          });
        } else {
          this.$message({
            type: "error",
            message: res.msg
          });
        }
      });
    },
  },
  created() {}
};
</script>

<style scoped>
.el-input__inner {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.narrow-container {
  max-width: 400px; /* 根据需要调整这个宽度 */
}
</style>
